﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace Abhimanu.Mobile.Models
{
    public class AskQuery
    {
        public long QueryID { get; set; }

        [Required]
        [DataType(DataType.Text)]
        [Display(Name = "Select Faculty")]
        public long FacultyID { get; set; }

        [Required]
        [DataType(DataType.Text)]
        [Display(Name = "Subject")]
        public string Subject { get; set; }

        [Required]
        [DataType(DataType.MultilineText)]
        [Display(Name = "Question")]
        public string Question { get; set; }

        public List<Query> Queries { get; set; }

        public List<Answer> Answers { get; set; }

        [Required]
        [DataType(DataType.MultilineText)]
        [Display(Name = "Reply")]
        public string Reply { get; set; }

        public List<SelectListItem> GetFacultyList()
        {
            List<SelectListItem> facultyList = new List<SelectListItem>();
            using (DB.AbhimanuDataContext dataContext = new DB.AbhimanuDataContext())
            {
                facultyList.Add(new SelectListItem() { Value = "", Text = "----Select----", Selected = true });
                var result = dataContext.UserInfos.Where(obj => (obj.LoginType == "F"));
                foreach (var item in result)
                {
                    facultyList.Add(new SelectListItem()
                    {
                        Text = string.Format("{0} {1}", item.FirstName, item.LastName),
                        Value = item.UserID.ToString()
                    });
                }
            }

            return facultyList;
        }
    }

    public class Query
    {
        public long QueryID { get; set; }

        public string Question { get; set; }
    }

    public class Answer
    {
        public long AnswerID { get; set; }

        public string AnswerText { get; set; }

        public string AnswerDate { get; set; }

        public string Faculty { get; set; }
    }
}